import { Toast } from 'antd-mobile'
const Ispass = (method, email, password, userName, phone) => {
    let reg = /^1[3-9]\d{9}$/
    if (method == 'register') {
        if (!userName || !password || !email || !phone) {
            Toast.show({
                icon: 'fail',
                content: '请填写完整信息',
            })
            return false
        }
        if (password.length < 6) {
            Toast.show({
                icon: 'fail',
                content: '密码长度不能小于6',
            })
            return false
        }
        if (email.indexOf('@') == -1) {
            Toast.show({
                icon: 'fail',
                content: '请输入正确的邮箱',
            })
            return false
        }
        if (phone.length != 11 || !reg.test(phone)) {
            Toast.show({
                icon: 'fail',
                content: '请输入正确的手机号',
            })
            return false
        }
        return true
    } else {
        if (!password || !email) {
            Toast.show({
                icon: 'fail',
                content: '请填写完整信息',
            })
            return false
        }
        if (password.length < 6) {
            Toast.show({
                icon: 'fail',
                content: '密码长度不能小于6',
            })
            return false
        }
        if (email.indexOf('@') == -1) {
            Toast.show({
                icon: 'fail',
                content: '请输入正确的邮箱',
            })
            return false
        }
        return true
    }
}
export default Ispass;